package com.zjb.wxlisener.control;

import com.zjb.wxlisener.JavaBean.Music;
import com.zjb.wxlisener.JavaBean.Result;
import com.zjb.wxlisener.service.SearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/search")
@Slf4j
public class SerrchControl {
    @Autowired
    SearchService searchService;


    @GetMapping("/searchMusic")
    public Result searchMusic(String name, String author) {
        log.info("根据name和author模糊查询:{},{}", name, author);
        List<Music> songs = searchService.selectSongs(name, author);
        if (songs==null){
            return Result.error("找不到结果");
        }
        return Result.success(songs);
    }
}
